package CPD;

import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JButton;
import java.awt.Point;

public class PanelSeleccion extends JFrame{
	private static final long serialVersionUID = 1L;
	private JPanel jPanelSeleccion = null;
	private JButton jButtonOk = null;
	private JButton jButtonCancel = null;
	
	private FrmTipo frm = null;
	
	public PanelSeleccion(FrmTipo oFrmTipo) {
  	  setFrmTipo(oFrmTipo);		
	}
	public JPanel getJPanelSeleccion() {
		if (jPanelSeleccion == null) {
			jPanelSeleccion = new JPanel();
			jPanelSeleccion.setLayout(null);
			jPanelSeleccion.setPreferredSize(new Dimension(120, 0));
			jPanelSeleccion.setVisible(false);
			jPanelSeleccion.add(getJButtonOk(), null);
			jPanelSeleccion.add(getJButtonCancel(), null);
		}
		return jPanelSeleccion;
	}

	/**
	 * This method initializes jButtonOk	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonOk() {
		if (jButtonOk == null) {
			jButtonOk = new JButton();
			jButtonOk.setText("ACEPTAR");
			jButtonOk.setPreferredSize(new Dimension(58, 26));
			jButtonOk.setSize(new Dimension(120, 24));
			jButtonOk.setLocation(new Point(0, 23));
			jButtonOk.setName("Aceptar");
			jButtonOk.setIcon(new ImageIcon(getClass().getResource("/iconos_3/16x16-free-application-icons/png/16x16/OK.png")));
			jButtonOk.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
					getFrmTipo().aceptar();
				}
			});
		}
		return jButtonOk;
	}

	/**
	 * This method initializes jButtonCancel	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonCancel() {
		if (jButtonCancel == null) {
			jButtonCancel = new JButton();
			jButtonCancel.setText("CANCELAR");
			jButtonCancel.setPreferredSize(new Dimension(58, 26));
			jButtonCancel.setLocation(new Point(0, 66));
			jButtonCancel.setSize(new Dimension(120, 24));
			jButtonCancel.setName("Cancelar");
			jButtonCancel.setIcon(new ImageIcon(getClass().getResource("/iconos_3/16x16-free-application-icons/png/16x16/Cancel.png")));
			jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
					getFrmTipo().cancelar();
				}
			});
		}
		return jButtonCancel;
	}
  	private void setFrmTipo(FrmTipo oFrmTipo){
		frm = oFrmTipo;
	}
	private FrmTipo getFrmTipo(){
		return frm;
	}
	public void mostrar(){
		jPanelSeleccion.setVisible(true);
	}
	public void ocultar(){
		jPanelSeleccion.setVisible(false);
	}
	public void activarAceptar(boolean opcion){
		jButtonOk.setEnabled(opcion);
	}
}
